# -*- coding:utf-8 -*-

'''
while循环 while里面可以添加条件

'''
'''
while True:
    print('人生苦短，我也有python')
'''



'''
while里面添加条件判断
count = 0
while count <= 100:
    count = count + 2
    print(count)
'''

# 通过while循环，打印1 2 3 4 5 6  8 9 10，里面没有7
count = 0
while count < 10:
    count = count + 1
    if count != 7:
        print(count)
print('结束')
# mac下快速注释用command+'/'，想取消再按一次

# 添加pass的写法，执行到pass，直接过，java中好像没有pass的写法
count = 0
while count < 10:
    count = count + 1
    if count == 7:
        pass
    else:
        print(count)
print('结束')

# break关键字的使用，终止当前循环,外层循环不会终止
# 通过break实现打印1-10
count = 1
while True:
    if count > 10:
        break
    print(count)
    count = count + 1
print('break结束')

# continue关键字的使用，直接跳到下一个循环，不再执行本次循环continue后面的代码
# 打印1~10，但是不包含7
count = 1
while count <= 10:
    if count == 7:
        count = count + 1
        continue
    print(count)
    count = count + 1
print('continue结束')

# while else，很少用，else里面代码块需要while循环条件不满足时才会执行
count = 1
while count <= 10:
    if count == 7:
        count = count + 1
        continue
    print(count)
    count = count + 1
else:
    print('这是else里面的代码块')
print('while else结束')
